import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.geom.Rectangle2D;
import java.io.Serializable;

public class PLShape implements Cloneable, Serializable {
	private static final long serialVersionUID = 1L;
	
	//quadrants can be either one through four
	int startingQuad; 
	int endingQuad; 
	
	public enum ShapeIdT {
		kMin(-1), 
		kLine(0), 
		kRect(1), 
		kEllipse(2), 
		kTriangle(3), 
		kMax(4);
		
		private int mId = 0;

		private ShapeIdT(int id) {setId(id);}
		
		public void setId(int id) {
			mId = id;
		}
		public int getId() {
			return mId;
		}
	}
	
	private ShapeIdT mShapeId;

	// mouse start and end
	protected Point mStart; 
	protected Point mEnd;
	
	// computed lines and the corners per shape
	protected PLLine[] mLines = null;
	protected Point[] mCorners = null;
		
	public PLShape() {mShapeId = ShapeIdT.kMin;}

	public PLShape(ShapeIdT id) {mShapeId = id;}

	public Object clone() throws CloneNotSupportedException  {
			PLShape  clone = (PLShape )super.clone();
			clone.Parse((Point)mStart.clone(), (Point)mEnd.clone());			
			return clone;
	}

	public Point GetStart() {
		return mStart;
	}

	public void SetStart(Point start) {
		mStart = start;
		SetStartingQuadrant(); 
	}

	public Point GetEnd() {
		return mEnd;
	}

	public void SetEnd(Point end) {
		mEnd = end;
		SetEndingQuadrant(); 
	}
	
	public boolean Parse(Point start, Point end) {
		SetStart(start);
		SetEnd(end);
		return true;
	}
	public void SetStartingQuadrant(){
		startingQuad = PLShapeUtils.GetQuadrant(mStart);
	}
	
	public void SetEndingQuadrant(){
		startingQuad = PLShapeUtils.GetQuadrant(mEnd);
	}
	public int GetStartingQuadrant(){return startingQuad;}
	public int GetEndingQuardrant(){return endingQuad;}
	
	public Shape GetJavaShape(){
		//dummy placeholder
		return null; 
	}
	
	public float GetArea(){
		return 0;
	}
	
	public void Draw(Graphics g) {}		

	public Point GetCenter(){
		return new Point((mStart.x + mEnd.x)/2, (mStart.y + mEnd.y)/2); 
	}
	
	public PLLine[] GetLines() {
		if (null == mLines)
			SetupLines();		
		return mLines;
	}
	
	public Point[] GetCorners() {
		if (null == mCorners)
			SetupCorners();		
		return mCorners;
	}

	public boolean IsValid() { return mShapeId.getId() > ShapeIdT.kMin.getId() && mShapeId.getId() < ShapeIdT.kMax.getId();}
	public ShapeIdT GetShapeId() {return mShapeId;}

	public static int GetNumShapes() {return ShapeIdT.kMax.getId();}
	

	// PROTECTED

	protected void SetupLines() {}
	protected void SetupCorners() {}

	
}
